/**
 * Created by thomas on 2017/5/8.
 */
function change_ul(obj){
    /*
    * obj.meth :post
    * obj:url url
    * obj,data data
    * obj.cb cb
    * */
    function XHR() {
        let xhr;
        try {xhr = new XMLHttpRequest();}
        catch(e) {
            let IEXHRVers =["Msxml3.XMLHTTP","Msxml2.XMLHTTP","Microsoft.XMLHTTP"];
            for (let i=0,len=IEXHRVers.length;i< len;i++) {
                try {xhr = new ActiveXObject(IEXHRVers[i]);}
                catch(e) {continue;}
            }
        }
        return xhr;
    }
    let xhr = XHR();
    xhr.open(obj.meth,obj.url,true);
    xhr.onreadystatechange = function () {
        if (xhr.readyState==4 && xhr.status ==200){
            obj.cb(xhr.responseText)
        }
    }
    //比GET请求多了一步
    if(obj.meth === 'post'){
        xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    }
    //另外,数据是通过send方法发送的
    xhr.send(obj.data)
    //xhr.send("weight="+sessionStorage.getItem("weight")+"&height="+sessionStorage.getItem("height")+"&age="+this.refs.age_n.innerText+"&openid="+"oT4UAxI5ETH4NwgzgNolmhp8fS-Y")
    //sessionStorage.setItem("age",this.refs.age_n.innerText);
}
export default change_ul;